﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WineDAL
{
    public class WineGoodsMessagesDAL
    {
        SQLHelper helper = new SQLHelper();
        /// <summary>
        /// 商品信息显示
        /// </summary>
        /// <returns></returns>
        public ArrayList GoodsMessages_Show()
        {
            DataTable table = helper.ExecDataTable_Proc("GoodsMessages_Show");
            System.Collections.ArrayList dic = new System.Collections.ArrayList();
            foreach (DataRow dr in table.Rows)
            {
                System.Collections.Generic.Dictionary<string, object> drow = new System.Collections.Generic.Dictionary<string, object>();
                foreach (DataColumn dc in table.Columns)
                {
                    drow.Add(dc.ColumnName, dr[dc.ColumnName]);
                }
                dic.Add(drow);
            }
            return dic;       
        }
        /// <summary>
        /// 返回查询结果
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public ArrayList Search_Show(string str)
        {
            SqlParameter par = new SqlParameter("@Content", str);
            DataTable table = helper.ExecDataTable_Proc("Search_Show", par);
            //JavaScriptSerializer jss = new JavaScriptSerializer();
            System.Collections.ArrayList dic = new System.Collections.ArrayList();
            foreach (DataRow dr in table.Rows)
            {
                System.Collections.Generic.Dictionary<string, object> drow = new System.Collections.Generic.Dictionary<string, object>();
                foreach (DataColumn dc in table.Columns)
                {
                    drow.Add(dc.ColumnName, dr[dc.ColumnName]);
                }
                dic.Add(drow);
            }
            return dic;
        }
        /// <summary>
        /// 返回查询结果
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public ArrayList BrandSearch(int str)
        {
            SqlParameter par = new SqlParameter("@Bid", str);
            DataTable table = helper.ExecDataTable_Proc("BrandSearch", par);
            //JavaScriptSerializer jss = new JavaScriptSerializer();
            System.Collections.ArrayList dic = new System.Collections.ArrayList();
            foreach (DataRow dr in table.Rows)
            {
                System.Collections.Generic.Dictionary<string, object> drow = new System.Collections.Generic.Dictionary<string, object>();
                foreach (DataColumn dc in table.Columns)
                {
                    drow.Add(dc.ColumnName, dr[dc.ColumnName]);
                }
                dic.Add(drow);
            }
            return dic;
        }
        /// <summary>
        /// 返回查询结果
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public ArrayList GoodsTypeSearch(int str)
        {
            SqlParameter par = new SqlParameter("@Typeid", str);
            DataTable table = helper.ExecDataTable_Proc("GoodsTypeSearch", par);
            //JavaScriptSerializer jss = new JavaScriptSerializer();
            System.Collections.ArrayList dic = new System.Collections.ArrayList();
            foreach (DataRow dr in table.Rows)
            {
                System.Collections.Generic.Dictionary<string, object> drow = new System.Collections.Generic.Dictionary<string, object>();
                foreach (DataColumn dc in table.Columns)
                {
                    drow.Add(dc.ColumnName, dr[dc.ColumnName]);
                }
                dic.Add(drow);
            }
            return dic;
        }
        /// <summary>
        /// 返回查询结果
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public ArrayList PriceSearch(decimal PriceMin, decimal PriceMax, int str)
        {
            SqlParameter[] par = { new SqlParameter("@PriceMin", PriceMin), new SqlParameter("@PriceMax", PriceMax), new SqlParameter("@Typeid", str) };
            DataTable table = helper.ExecDataTable_Proc("PriceSearch", par);
            //JavaScriptSerializer jss = new JavaScriptSerializer();
            System.Collections.ArrayList dic = new System.Collections.ArrayList();
            foreach (DataRow dr in table.Rows)
            {
                System.Collections.Generic.Dictionary<string, object> drow = new System.Collections.Generic.Dictionary<string, object>();
                foreach (DataColumn dc in table.Columns)
                {
                    drow.Add(dc.ColumnName, dr[dc.ColumnName]);
                }
                dic.Add(drow);
            }
            return dic;
        }
    }
}
